import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:finance_app/src/widgets/wrapper/normal_form_wrapper.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class ReimburseItem extends StatelessWidget {
  final String name;
  final String title;
  final String time;
  final String status;
  final String currency;
  final double amount;
  final String realStatus;

  const ReimburseItem(
      {Key key,
      this.name,
      this.title,
      this.time,
      this.status,
      this.currency,
      this.amount,
      this.realStatus})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: getDp(110),
      child: NormalFormWrapper(
        leftPadding: getDp(35),
        rightPadding: getDp(35),
        topPadding: getDp(21),
        bottomPadding: getDp(19),
        hasBottomBorder: true,
        child: Stack(
          clipBehavior: Clip.none,
          children: [
            Positioned(
              top: 0,
              bottom: 0,
              left: 0,
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  SizedBox(
                    child: Text(
                      name,
                      style: TextStyle(
                        color: aceBlackColor,
                        fontSize: getSp(18),
                        fontWeight: FontWeight.w700,
                        height: 14 / 18,
                      ),
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                    ),
                    width: getDp(220),
                  ),
                  SizedBox(
                    height: getDp(8),
                  ),
                  SizedBox(
                    width: getDp(140),
                    child: Text(
                      title,
                      style: TextStyle(
                        color: aceBlueColor,
                        fontSize: getSp(16),
                        fontWeight: FontWeight.w700,
                        height: 16 / 14,
                      ),
                      maxLines: 1,
                    ),
                  ),
                  Text(
                    time,
                    style: TextStyle(
                      color: aceDarkGrayColor,
                      fontSize: getSp(16),
                      fontWeight: FontWeight.w400,
                      height: 16 / 14,
                    ),
                  ),
                ],
              ),
            ),
            Positioned(
              top: 0,
              bottom: 0,
              right: 0,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  if (status != null && status != 'Paid')
                    status == 'Upcoming'
                        ? BlueTagWidget(
                            content: status,
                          )
                        : status == 'Rejected'
                            ? NormalRedTagWidget(
                                content: status,
                              )
                            : RedTagWidget(
                                content: status,
                              ),
                  SizedBox(
                    height: getDp(9),
                  ),
                  Text(
                    '$currency ${CashUtils.formatCashAmount(amount)}',
                    style: TextStyle(
                      color: aceBlackColor,
                      fontSize: getSp(16),
                      fontWeight: FontWeight.w700,
                      height: 14 / 16,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
    super.debugFillProperties(properties);
    properties.add(DoubleProperty('amount', amount));
    properties.add(StringProperty('currency', currency));
    properties.add(StringProperty('status', status));
    properties.add(StringProperty('time', time));
    properties.add(StringProperty('title', title));
    properties.add(StringProperty('name', name));
    properties.add(StringProperty('realStatus', realStatus));
  }
}
